import styles from './index.module.scss'

type Props = {
  type: '' | 'gender' | 'photo',
  hideList: () => void,
  onUpdate: (key: string, value: string) => void
}
// 性别选项
const genderList = [
  { title: '男', value: '0' },
  { title: '女', value: '1' }
]
// 拍照选项
const photoList = [
  { title: '拍照', value: '' },
  { title: '本地选择', value: '' }
]

const EditList = ({ hideList, type, onUpdate }: Props) => {
  const list = type === 'gender' ? genderList : photoList
  return (
    <div className={styles.root}>
      {
        list.map(item =>
        (<div
          className="list-item"
          key={item.title}
          onClick={() => onUpdate(type, item.value)}
        >
          {item.title}
        </div>)
        )
      }
      <div className="list-item" onClick={hideList}>取消</div>
    </div>
  )
}

export default EditList
